import cv2
import sys
import os
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QApplication
from PyQt5.QtCore import QThread, pyqtSignal

from ui.ui.main_ui import *
from ui.ui.ui_base import ui_base
from ui.video_ui import video_ui


class main_ui(QMainWindow, Ui_MainWindow, ui_base):
    open_path = os.environ['HOME']
    capture = None


    def __init__(self, admin, parent=None):
        super(main_ui, self).__init__(parent)
        self.admin = admin
        self.setupUi(self)
        self.set_activity()

    def set_activity(self):
        self.lineEdit.setText('0')
        self.pushButton_2.clicked.connect(self.selectfile)
        self.pushButton.clicked.connect(self.openfile)

    def selectfile(self):
        file_name = QFileDialog.getOpenFileName(self, '选择文件', self.open_path, '')
        self.lineEdit.setText(file_name[0])

    def openfile(self):
        path_name = self.lineEdit.text()
        self.admin.video_therad.set_capture(path_name)




if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = main_ui()
    win.show()
    app.exec_()
